﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3.Chapt3_3ObjectClass
{
    class Chapt3_3_3GetTypeAndTypeof
    {
        public class Point { public int X, Y; }
        static void _Main()
        {
            /*
             *  Gettype运行时计算，typeof在编译时静态计算
                在类型实例上调用GetType方法
                在类型名称上使用typeof运算符
             */
            Point p = new Point();
            Console.WriteLine(p.GetType().Name); //Point
            Console.WriteLine(typeof(Point).Name);//Point
            Console.WriteLine(p.GetType() == typeof(Point));    //True
            Console.WriteLine(p.X.GetType().Name);              //Int32
            Console.WriteLine(p.Y.GetType().FullName);      //System.Int32
        }
    }
}
